
LIBNAME = libsubcatch.so

ROOTDIR=$(shell pwd)
INC= -I./src 
DIR = $(ROOTDIR)/src
CFLAGS += -shared -fPIC
SCRCS	:= $(foreach dir,$(DIR),$(wildcard $(dir)/*.c))
#SCRCS	:=$(DIR)/*.c
OBJS	:= $(patsubst %.c ,%.o ,$(SCRCS))
#$(shell echo "1$(SCRCS)" )
CC		= gcc

.PHONY: all
all: libs  topic sub

%.o:%.c
	$(CC)    -o $@ -c $^

libs: $(OBJS)
	$(CC) $(OBJS) $(CFLAGS) -o $(LIBNAME)

topic:libs
	$(CC) example/test_topic.c   -L./ -lsubcatch -I./src   -o topic

sub:libs
	$(CC) example/test_sub.c   -L./ -lsubcatch -lpthread -I./src   -o sub

clean:
	rm *.so topic